local que_heming = fk.CreateSkill {
    name = "que_heming",
    tags = { Skill.Limited },
    anim_type = "support",
}

Fk:loadTranslationTable {
    ["que_heming"] = "合鸣",
    [":que_heming"] = "限定技，当其他角色死亡时，若〖鸾歌〗至少记录了一张牌，你可以回复一点体力，选择一项(X为其手牌数，至少为1，至多为3)：<br>" ..
        "1.失去〖鸾歌〗，<a href='qingkonggai'>修改〖青空〗</a>并填充X次；<br>2.失去〖青空〗，随机获得〖鸾歌〗中的X张牌并清除〖鸾歌〗。",

    ["qingkonggai"] = "☆青空：出牌阶段限零次，你可以视为使用一张本回合未使用且结算过的普通锦囊牌(当你受到伤害后，此技能使用次数+1)。",

    ["loseluange"] = "失去〖鸾歌〗，修改〖青空〗并填充 %arg 次数",
    ["loseqingkong"] = "失去〖青空〗，随机获得〖鸾歌〗中的的 %arg 张牌并清除〖鸾歌〗",

    ["$que_heming1"] = " ",
    ["$que_heming2"] = " ",
}

que_heming:addEffect(fk.Death, {
    can_trigger = function(self, event, target, player, data)
        return player:hasSkill(que_heming.name) and #player:getTableMark("@$que_luange_cards") > 0 and
            player:usedSkillTimes(que_heming.name, Player.HistoryGame) == 0
    end,
    on_cost = function(self, event, target, player, data) --cost选择选项案例
        local room = player.room
        local n = math.max(math.min(#target:getCardIds("h"), 3), 1)
        local choices = { "loseluange:::" .. n, "loseqingkong:::" .. n }
        local choice = room:askToChoice(player, {
            choices = choices,
            skill_name = que_heming.name,
        })
        if choice then
            event:setCostData(self, { choice = choice })
            return true
        end
    end,
    on_use = function(self, event, target, player, data)
        local room = player.room
        local n = math.max(math.min(#target:getCardIds("h"), 3), 1)
        local choice = event:getCostData(self).choice
        room:recover {
            who = player,
            num = 1,
            recoverBy = player,
            skillName = que_heming.name,
        }
        if choice == "loseluange:::" .. n then
            room:handleAddLoseSkills(player, "-que_luange")
            room:setPlayerMark(player, "que_qingkong_gai", 1)
            room:addPlayerMark(player, "que_qingkong", n)
        else
            room:handleAddLoseSkills(player, "-que_qingkong")
            local mark = player:getTableMark("@$que_luange_cards")
            local cards = table.filter(table.connect(player.room.draw_pile, player.room.discard_pile), function(id)
                return table.contains(mark, Fk:getCardById(id).trueName)
            end)
            if #cards > 0 then
                room:moveCardTo(table.random(cards, n), Card.PlayerHand, player,
                    fk.ReasonJustMove, que_heming.name, nil, false, player)
            end
        end
        room:setPlayerMark(player, "@$que_luange_cards", 0)
    end,
})
return que_heming
